package cn.qzbook.dao.ManyToMany;

import cn.qzbook.MybatisTool;
import cn.qzbook.domain.Stu;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

public class StuDao {


    private SqlSession sqlSession = MybatisTool.sqlSessionFactory().openSession(true);

    @Test
    public void test(){
        StuDao dao = new StuDao();
//        dao.selectStuAndAllTeachers(2);
        dao.selectStuAndAllTeachersList();
    }


    //给定学生的sid	 -- > 查询学生的信息	+	所有课程的老师的信息
    public void selectStuAndAllTeachers(int id){
        Stu stus = sqlSession.selectOne("selectStuAndAllTeachers", id);
        System.out.println(stus);
    }

    //全表通查   查询学生所有的的信息   +  学生对应的所有课程老师的信息
    public void selectStuAndAllTeachersList(){
        List<Stu> stus = sqlSession.selectList("selectStuAndAllTeachersList");
        for (Stu stu : stus){
            System.out.println(stu);
        }
    }

}
